package org.blue.eventbus;

import org.blue.eventbus.annotation.Recieve;

public class Test {

	public static void main(String[] args) {
		EventBus bus = EventBus.getDefault();
		bus.recieve(Test.class).subscribe(event -> {
			System.out.println("event=" + event);
		});
		
		// ......
		Test t = new Test();
		bus.post(t);
	}

	public Test() {
		EventBus bus = EventBus.getDefault();
		bus.bind(this);
	}

	@Recieve(eventTypes = Test.class)
	private void onReceive(Object event) {
		System.out.println("event2=" + event);
		EventBus bus = EventBus.getDefault();
		bus.unbind(this);
	}

}
